package com.cac.demo.service.msTaskAo;
import com.cac.demo.dao.msTaskAo.MsTaskAoDao;


import com.cac.demo.util.adapter.DaoException;
import com.cac.demo.util.adapter.QueryReqBean;
import com.cac.demo.util.adapter.QueryRespBean;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;

/**
 * @program test-curd
 * @description AO分拣任务服务
 * @author: LSL
 * @create: 2022-08-29-15-26
 **/
@Service
public class MsTaskAoService {
    @Autowired
    private MsTaskAoDao msTaskAoDao;

    //查询工作包下所有ao
    public QueryRespBean<HashMap> searchByPage(QueryReqBean<HashMap> queryReqBean, String msTaskPackageId) {
        QueryRespBean<HashMap> queryRespBean = new QueryRespBean<>();
        try {
            PageHelper.startPage(queryReqBean.getPageParameter());
            Page<HashMap> dataList = msTaskAoDao.searchMsTaskAoDaoByPage(msTaskPackageId);
            queryRespBean.setResult(dataList);
            return queryRespBean;
        } catch (Exception e) {
            throw new DaoException(e.getMessage());
        }
    }

    //工艺更改ao查询
    public QueryRespBean<HashMap> searchChangedAo(QueryReqBean<HashMap> queryReqBean) {
        QueryRespBean<HashMap> queryRespBean = new QueryRespBean<>();
        try {
            PageHelper.startPage(queryReqBean.getPageParameter());
            Page<HashMap> dataList = msTaskAoDao.searchAoChanged();
            queryRespBean.setResult(dataList);
            return queryRespBean;
        } catch (Exception e) {
            throw new DaoException(e.getMessage());
        }
    }

    //工艺更改物料查询
    public QueryRespBean<HashMap> searchMaterialChanged(QueryReqBean<HashMap> queryReqBean, String msTaskAoId) {
        QueryRespBean<HashMap> queryRespBean = new QueryRespBean<>();
        try {
            PageHelper.startPage(queryReqBean.getPageParameter());
            Page<HashMap> dataList = msTaskAoDao.searchMaterialChanged(msTaskAoId);
            queryRespBean.setResult(dataList);
            return queryRespBean;
        } catch (Exception e) {
            throw new DaoException(e.getMessage());
        }
    }
}

